//
//  LGPatientRiskMonitorCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2024/8/2.
//

#import "LGPatientRiskMonitorCell.h"

@interface LGPatientRiskMonitorCell()
/**   */
@property (nonatomic , strong)UIImageView *iconView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *statusLabel;

@end

@implementation LGPatientRiskMonitorCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setType:(LGPositionType)type{
    [super setType:type];
    CGFloat bottom = (type == LGPositionTypeBottom)?-viewPix(24):-viewPix(8);
    [self.iconView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView).offset(bottom);
    }];
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:dataDic[@"icon"]]];
    self.titleLabel.text = LGNSString(dataDic[@"title"]);
    self.statusLabel.text = LGNSString(dataDic[@"desc"]);
    NSString *colorStr = ([dataDic[@"status"] integerValue]==0)?@"#909399":@"#DD3030";
    self.statusLabel.textColor = [UIColor colorWithString:colorStr];
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.contentView addSubview:self.iconView];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.statusLabel];
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(viewPix(8));
        make.left.equalTo(self.contentView).offset(viewPix(28));
        make.bottom.equalTo(self.contentView).offset(-viewPix(8));
        make.width.height.equalTo(@(viewPix(24)));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).offset(viewPix(6));
        make.centerY.equalTo(self.iconView);
    }];
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-viewPix(28));
        make.centerY.equalTo(self.iconView);
    }];
}

-(UIImageView *)iconView{
    if(!_iconView){
        _iconView = [[UIImageView alloc]init];
    }
    return _iconView;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UILabel *)statusLabel{
    if(!_statusLabel){
        _statusLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(16) textAlignment:NSTextAlignmentRight lines:1];
    }
    return _statusLabel;
}

@end
